package com.xinfu.newproject.presenter;

import com.xinfu.newproject.bean.matter_repair.QueryRepairPartsBean;
import com.xinfu.newproject.bean.matter_repair.QueryRepairPartsBody;
import com.xinfu.newproject.callback.MyCallBack;
import com.xinfu.newproject.model.matter_repair.QueryRepairPartsPartsModel;
import com.xinfu.newproject.view.IView;

import io.reactivex.disposables.Disposable;

public class QueryRepairPartsPresenter {
    private IView.IQueryRepairPartsView mIQueryRepairPartsView;

    private QueryRepairPartsPartsModel mQueryRepairPartsModel;

    public QueryRepairPartsPresenter(IView.IQueryRepairPartsView iQueryRepairPartsView) {
        this.mIQueryRepairPartsView = iQueryRepairPartsView;
        mQueryRepairPartsModel = new QueryRepairPartsPartsModel();
    }

    /**
     * 查询报事报修
     */
    public void queryRepair() {

        QueryRepairPartsBody queryRepairPartsBody = new QueryRepairPartsBody(mIQueryRepairPartsView.header(), mIQueryRepairPartsView.userId());

        mQueryRepairPartsModel.queryRepairParts(queryRepairPartsBody, new MyCallBack<QueryRepairPartsBean>() {
            @Override
            public void onSuccess(QueryRepairPartsBean queryRepairPartsBean) {

                if (queryRepairPartsBean.isSuccess()) {
                    mIQueryRepairPartsView.getData(queryRepairPartsBean);
                } else {
                    mIQueryRepairPartsView.showToast(queryRepairPartsBean.getMessage());
                }
//                mIQueryRepairPartsView.showToast(queryRepairPartsBean.getMessage());
            }

            @Override
            public void onError(String header, String message) {

                mIQueryRepairPartsView.showToast(message);
            }

            @Override
            public void onDispose(Disposable disposable) {
                mIQueryRepairPartsView.closeDispose(disposable);
            }
        });


    }


//    private Map<String, String> createParaMap() {
//        Map<String, String> paraMap = new HashMap<>();
//        paraMap.put("userName", mIRegisterView.getUserName());
//        return paraMap;
//    }

}
